
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1.系统限流 · 计算机 ,java , 大数据 基础知识体系</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="hzh">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../高可用系统/2.服务熔断.html" />
    
    
    <link rel="prev" href="../架构/0.微服务架构与soa架构.html" />
    

    
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">操作系统</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../操作系统/1.基本概述.html">
            
                <a href="../操作系统/1.基本概述.html">
            
                    
                    1.操作系统基本概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../操作系统/2.进程管理之进程与线程.html">
            
                <a href="../操作系统/2.进程管理之进程与线程.html">
            
                    
                    2.进程管理之进程与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../操作系统/3.进程管理之处理机调度.html">
            
                <a href="../操作系统/3.进程管理之处理机调度.html">
            
                    
                    3.进程管理之处理机调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../操作系统/4.进程管理之进程同步.html">
            
                <a href="../操作系统/4.进程管理之进程同步.html">
            
                    
                    4.进程管理之进程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../操作系统/5.内存管理之基本概念.html">
            
                <a href="../操作系统/5.内存管理之基本概念.html">
            
                    
                    5.内存管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../操作系统/6.内存管理之虚拟内存.html">
            
                <a href="../操作系统/6.内存管理之虚拟内存.html">
            
                    
                    6.内存管理之虚拟内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../操作系统/7.IO设备管理之基本概念.html">
            
                <a href="../操作系统/7.IO设备管理之基本概念.html">
            
                    
                    7.IO设备管理之基本概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../操作系统/8.面试题总结一.html">
            
                <a href="../操作系统/8.面试题总结一.html">
            
                    
                    8.面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">计算机网络篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../计算机网络/1.计算机网络入门基础概念.html">
            
                <a href="../计算机网络/1.计算机网络入门基础概念.html">
            
                    
                    1.计算机网络入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../计算机网络/2.计算机网络通信基础.html">
            
                <a href="../计算机网络/2.计算机网络通信基础.html">
            
                    
                    2.计算机网络通信入门文章(必读)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../计算机网络/3.数据链路层.html">
            
                <a href="../计算机网络/3.数据链路层.html">
            
                    
                    3.数据链路层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../计算机网络/4.网络层1.html">
            
                <a href="../计算机网络/4.网络层1.html">
            
                    
                    4.网络层(一)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../计算机网络/5.网络层2.html">
            
                <a href="../计算机网络/5.网络层2.html">
            
                    
                    5.网络层(二)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../计算机网络/6.传输层.html">
            
                <a href="../计算机网络/6.传输层.html">
            
                    
                    6.传输层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../计算机网络/7.应用层.html">
            
                <a href="../计算机网络/7.应用层.html">
            
                    
                    7.应用层(⭐)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../计算机网络/10.HTTP相关协议.html">
            
                <a href="../计算机网络/10.HTTP相关协议.html">
            
                    
                    8.HTTP相关及发展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" >
            
                <span>
            
                    
                    9.websocket
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="../计算机网络/9.面试题二.html">
            
                <a href="../计算机网络/9.面试题二.html">
            
                    
                    面试题总结一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">数据结构篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../数据结构/1.图论.html">
            
                <a href="../数据结构/1.图论.html">
            
                    
                    1.图论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../数据结构/2.图论例题.html">
            
                <a href="../数据结构/2.图论例题.html">
            
                    
                    2.图论例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../数据结构/3.散列表.html">
            
                <a href="../数据结构/3.散列表.html">
            
                    
                    3.散列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../数据结构/4.排序算法.html">
            
                <a href="../数据结构/4.排序算法.html">
            
                    
                    4.排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../数据结构/5.排序列题.html">
            
                <a href="../数据结构/5.排序列题.html">
            
                    
                    5.排序算法例题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../数据结构/6.树论.html">
            
                <a href="../数据结构/6.树论.html">
            
                    
                    6.树论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../数据结构/7.树论例题.html">
            
                <a href="../数据结构/7.树论例题.html">
            
                    
                    7.树论例题.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../数据结构/9.模板.html">
            
                <a href="../数据结构/9.模板.html">
            
                    
                    数据结构模板
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">算法篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../算法/leetCode周赛题解.html">
            
                <a href="../算法/leetCode周赛题解.html">
            
                    
                    leetCode周赛记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../算法/1.时间复杂度.html">
            
                <a href="../算法/1.时间复杂度.html">
            
                    
                    1.时间复杂度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../算法/2.深度优先搜索.html">
            
                <a href="../算法/2.深度优先搜索.html">
            
                    
                    2.深度优先搜索算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../算法/2.深度优先搜索题目集.html">
            
                <a href="../算法/2.深度优先搜索题目集.html">
            
                    
                    2.深搜题目集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../算法/3.广度优先搜索.html">
            
                <a href="../算法/3.广度优先搜索.html">
            
                    
                    3.广度优先搜索算法
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JVM篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../jvm/1.jvm内存结构.html">
            
                <a href="../jvm/1.jvm内存结构.html">
            
                    
                    1.jvm内存结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../jvm/2.HotSpot虚拟机对象探秘.html">
            
                <a href="../jvm/2.HotSpot虚拟机对象探秘.html">
            
                    
                    2.HotSpot虚拟机对象探秘.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../jvm/3.对象存亡与垃圾收集算法.html">
            
                <a href="../jvm/3.对象存亡与垃圾收集算法.html">
            
                    
                    3.对象存亡与垃圾收集算法.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                <a href="../jvm/4.HotSpot的算法细节与垃圾收集器.html">
            
                    
                    4.HotSpot的算法细节与垃圾收集器.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../jvm/5.内存分配与回收策略.html">
            
                <a href="../jvm/5.内存分配与回收策略.html">
            
                    
                    5.内存分配与回收策略.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../jvm/6.类文件结构.html">
            
                <a href="../jvm/6.类文件结构.html">
            
                    
                    6.类文件结构.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="../jvm/7.类加载机制.html">
            
                <a href="../jvm/7.类加载机制.html">
            
                    
                    7.类加载机制.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="../jvm/8.jvm逃逸分析.html">
            
                <a href="../jvm/8.jvm逃逸分析.html">
            
                    
                    8.逃逸分析技术
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">多线程篇</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../多线程/basic/0.多线程路线图.html">
            
                <a href="../多线程/basic/0.多线程路线图.html">
            
                    
                    1.多线程学习路线图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../多线程/basic/0.java内存模型与线程.html">
            
                <a href="../多线程/basic/0.java内存模型与线程.html">
            
                    
                    2.java内存模型与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../多线程/3.并行程序基础.html">
            
                <a href="../多线程/3.并行程序基础.html">
            
                    
                    2.并行程序基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../多线程/basic/0.jhappenBefore与jvm指令重排.html">
            
                <a href="../多线程/basic/0.jhappenBefore与jvm指令重排.html">
            
                    
                    3.happenBefore与jvm指令重排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="../多线程/basic/1.synchronized与volatile.html">
            
                <a href="../多线程/basic/1.synchronized与volatile.html">
            
                    
                    4.synchronized与volatile.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="../多线程/basic/2.ThreadLocal.html">
            
                <a href="../多线程/basic/2.ThreadLocal.html">
            
                    
                    5.ThreadLocal.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="../多线程/cas/1.乐观锁与悲观锁.html">
            
                <a href="../多线程/cas/1.乐观锁与悲观锁.html">
            
                    
                    6.乐观锁与悲观锁.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="../多线程/cas/2.CAS与atomic类.html">
            
                <a href="../多线程/cas/2.CAS与atomic类.html">
            
                    
                    7.CAS与atomic类.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="../多线程/aqs/1.AQS.html">
            
                <a href="../多线程/aqs/1.AQS.html">
            
                    
                    8.AQS.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="../多线程/aqs/2.基于AQS的并发工具.html">
            
                <a href="../多线程/aqs/2.基于AQS的并发工具.html">
            
                    
                    9.基于AQS的并发工具.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="../多线程/blockingQueue/1.阻塞队列.html">
            
                <a href="../多线程/blockingQueue/1.阻塞队列.html">
            
                    
                    10.阻塞队列.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="../多线程/pond/1.线程池与底层原理.html">
            
                <a href="../多线程/pond/1.线程池与底层原理.html">
            
                    
                    11.线程池与底层原理.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.13" data-path="../多线程/10面试题一.html">
            
                <a href="../多线程/10面试题一.html">
            
                    
                    12.面试题一
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.14" data-path="../多线程/10面试题二.html">
            
                <a href="../多线程/10面试题二.html">
            
                    
                    13.面试题二.md
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">java集合篇</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../basic/collection/1.java集合.html">
            
                <a href="../basic/collection/1.java集合.html">
            
                    
                    1.集合架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../basic/collection/2.HashMap源码分析.html">
            
                <a href="../basic/collection/2.HashMap源码分析.html">
            
                    
                    2.hashMap底层原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../basic/collection/3.ConcurrentHashMap分析.html">
            
                <a href="../basic/collection/3.ConcurrentHashMap分析.html">
            
                    
                    3.ConcurrentHashMap分析
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">设计模式篇</li>
        
        
    
        <li class="chapter " data-level="8.1" >
            
                <span>
            
                    
                    1.创造型模式
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="../设计模式/factory/三种工厂模式介绍.html">
            
                <a href="../设计模式/factory/三种工厂模式介绍.html">
            
                    
                    三种工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="../设计模式/factory/实战工厂模式.html">
            
                <a href="../设计模式/factory/实战工厂模式.html">
            
                    
                    实战工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="../设计模式/factory/实战抽象工厂模式.html">
            
                <a href="../设计模式/factory/实战抽象工厂模式.html">
            
                    
                    实战抽象工厂模式
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">mysql篇</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../数据库/mysql/1.b树b+树的底层原理.html">
            
                <a href="../数据库/mysql/1.b树b+树的底层原理.html">
            
                    
                    1.mysql索引基础之b树与b+树⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../数据库/mysql/2.mysql索引.html">
            
                <a href="../数据库/mysql/2.mysql索引.html">
            
                    
                    2.mysql索引及优化⭐⭐⭐⭐
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../数据库/mysql/3.mysql存储引擎.html">
            
                <a href="../数据库/mysql/3.mysql存储引擎.html">
            
                    
                    3.mysql存储引擎.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                <a href="../数据库/mysql/4.多版本并发控制之mvcc原理.html">
            
                    
                    4.多版本并发控制之mvcc原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.5" data-path="../数据库/mysql/4.mysql事务.html">
            
                <a href="../数据库/mysql/4.mysql事务.html">
            
                    
                    5.mysql事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.6" data-path="../数据库/mysql/5.mysql锁机制.html">
            
                <a href="../数据库/mysql/5.mysql锁机制.html">
            
                    
                    6.mysql的锁机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.7" data-path="../数据库/mysql/6.mysql面试题一.html">
            
                <a href="../数据库/mysql/6.mysql面试题一.html">
            
                    
                    7.mysql面试题一
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高并发中间件篇</li>
        
        
    

    
        
        <li class="header">架构理论篇</li>
        
        
    
        <li class="chapter " data-level="11.1" data-path="../架构/0.架构演进.html">
            
                <a href="../架构/0.架构演进.html">
            
                    
                    1.架构演进
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="11.2" data-path="../架构/0.微服务架构与soa架构.html">
            
                <a href="../架构/0.微服务架构与soa架构.html">
            
                    
                    2.微服务架构与soa架构
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">高可用系统篇</li>
        
        
    
        <li class="chapter active" data-level="12.1" data-path="1.限流.html">
            
                <a href="1.限流.html">
            
                    
                    1.系统限流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="../高可用系统/2.服务熔断.html">
            
                <a href="../高可用系统/2.服务熔断.html">
            
                    
                    2.服务熔断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="12.3" data-path="../高可用系统/3.服务降级.html">
            
                <a href="../高可用系统/3.服务降级.html">
            
                    
                    3.服务降级
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">spring-cloud 微服务篇</li>
        
        
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >1.系统限流</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;"><b></b>&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;</a></li><li><span class="title-icon "></span><a href="#&#x9650;&#x6D41;&#x65B9;&#x6CD5;"><b></b>&#x9650;&#x6D41;&#x65B9;&#x6CD5;</a></li><ul><li><span class="title-icon "></span><a href="#&#x8BA1;&#x6570;&#x5668;"><b></b>&#x8BA1;&#x6570;&#x5668;</a></li><li><span class="title-icon "></span><a href="#&#x6ED1;&#x52A8;&#x7A97;&#x53E3;"><b></b>&#x6ED1;&#x52A8;&#x7A97;&#x53E3;</a></li><li><span class="title-icon "></span><a href="#&#x6F0F;&#x6876;&#x7B97;&#x6CD5;"><b></b>&#x6F0F;&#x6876;&#x7B97;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;"><b></b>&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;"><b></b>&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;</a></li><ul><li><span class="title-icon "></span><a href="#spring-cloud-gateway"><b></b>spring cloud gateway</a></li><li><span class="title-icon "></span><a href="#sentinel"><b></b>sentinel</a></li><li><span class="title-icon "></span><a href="#&#x603B;&#x7ED3;"><b></b>&#x603B;&#x7ED3;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;"><a name="&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;" class="anchor-navigation-ex-anchor" href="#&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;" class="plugin-anchor" href="#&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EC0;&#x4E48;&#x662F;&#x9650;&#x6D41;</h2>
<blockquote>
<p>&#x9650;&#x6D41;&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;&#x670D;&#x52A1;&#x964D;&#x7EA7;&#x7684;&#x4E00;&#x79CD;&#xFF0C;&#x9650;&#x6D41;&#x5C31;&#x662F;&#x9650;&#x5236;&#x7CFB;&#x7EDF;&#x7684;&#x8F93;&#x5165;&#x548C;&#x8F93;&#x51FA;&#x6D41;&#x91CF;&#x5DF2;&#x8FBE;&#x5230;&#x4FDD;&#x62A4;&#x7CFB;&#x7EDF;&#x7684;&#x76EE;&#x7684;&#x3002;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#x7CFB;&#x7EDF;&#x7684;&#x541E;&#x5410;&#x91CF;&#x662F;&#x53EF;&#x4EE5;&#x88AB;&#x6D4B;&#x7B97;&#x7684;&#xFF0C;&#x4E3A;&#x4E86;&#x4FDD;&#x8BC1;&#x7CFB;&#x7EDF;&#x7684;&#x7A33;&#x5B9A;&#x8FD0;&#x884C;&#xFF0C;&#x4E00;&#x65E6;&#x8FBE;&#x5230;&#x7684;&#x9700;&#x8981;&#x9650;&#x5236;&#x7684;&#x9608;&#x503C;&#xFF0C;&#x5C31;&#x9700;&#x8981;&#x9650;&#x5236;&#x6D41;&#x91CF;&#x5E76;&#x91C7;&#x53D6;&#x4E00;&#x4E9B;&#x63AA;&#x65BD;&#x4EE5;&#x5B8C;&#x6210;&#x9650;&#x5236;&#x6D41;&#x91CF;&#x7684;&#x76EE;&#x7684;&#x3002;&#x6BD4;&#x5982;&#xFF1A;&#x5EF6;&#x8FDF;&#x5904;&#x7406;&#xFF0C;&#x62D2;&#x7EDD;&#x5904;&#x7406;&#xFF0C;&#x6216;&#x8005;&#x90E8;&#x5206;&#x62D2;&#x7EDD;&#x5904;&#x7406;&#x7B49;&#x7B49;&#x3002;</p>
</blockquote>
<h2 id="&#x9650;&#x6D41;&#x65B9;&#x6CD5;"><a name="&#x9650;&#x6D41;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x9650;&#x6D41;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x9650;&#x6D41;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x9650;&#x6D41;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9650;&#x6D41;&#x65B9;&#x6CD5;</h2>
<h3 id="&#x8BA1;&#x6570;&#x5668;"><a name="&#x8BA1;&#x6570;&#x5668;" class="anchor-navigation-ex-anchor" href="#&#x8BA1;&#x6570;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x8BA1;&#x6570;&#x5668;" class="plugin-anchor" href="#&#x8BA1;&#x6570;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8BA1;&#x6570;&#x5668;</h3>
<h4 id="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><a name="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;" class="plugin-anchor" href="#&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;</h4>
<ul>
<li>&#x63A7;&#x5236;&#x5355;&#x4F4D;&#x65F6;&#x95F4;&#x5185;&#x7684;&#x8BF7;&#x6C42;&#x6570;&#x91CF;</li>
</ul>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> java.util.concurrent.atomic.AtomicInteger;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span> </span>{
    <span class="hljs-comment">/**
     * &#x6700;&#x5927;&#x8BBF;&#x95EE;&#x6570;&#x91CF;
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> limit = <span class="hljs-number">10</span>;
    <span class="hljs-comment">/**
     * &#x8BBF;&#x95EE;&#x65F6;&#x95F4;&#x5DEE;
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">long</span> timeout = <span class="hljs-number">1000</span>;
    <span class="hljs-comment">/**
     * &#x8BF7;&#x6C42;&#x65F6;&#x95F4;
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">long</span> time;
    <span class="hljs-comment">/**
     * &#x5F53;&#x524D;&#x8BA1;&#x6570;&#x5668;
     */</span>
    <span class="hljs-keyword">private</span> AtomicInteger reqCount = <span class="hljs-keyword">new</span> AtomicInteger(<span class="hljs-number">0</span>);

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">limit</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">long</span> now = System.currentTimeMillis();
        <span class="hljs-keyword">if</span> (now &lt; time + timeout) {
            <span class="hljs-comment">// &#x5355;&#x4F4D;&#x65F6;&#x95F4;&#x5185;</span>
            reqCount.addAndGet(<span class="hljs-number">1</span>);
            <span class="hljs-keyword">return</span> reqCount.get() &lt;= limit;
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">// &#x8D85;&#x51FA;&#x5355;&#x4F4D;&#x65F6;&#x95F4;</span>
            time = now;
            reqCount = <span class="hljs-keyword">new</span> AtomicInteger(<span class="hljs-number">0</span>);
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
        }
    }
}
</code></pre>
<ul>
<li>&#x52A3;&#x52BF;<ul>
<li>&#x5047;&#x8BBE;&#x5728; 00:01 &#x65F6;&#x53D1;&#x751F;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;,&#x5728; 00:01-00:58 &#x4E4B;&#x95F4;&#x4E0D;&#x5728;&#x53D1;&#x9001;&#x8BF7;&#x6C42;,&#x5728; 00:59 &#x65F6;&#x53D1;&#x9001;&#x5269;&#x4E0B;&#x7684;&#x6240;&#x6709;&#x8BF7;&#x6C42; <code>n-1</code> (n &#x4E3A;&#x9650;&#x6D41;&#x8BF7;&#x6C42;&#x6570;&#x91CF;),&#x5728;&#x4E0B;&#x4E00;&#x5206;&#x949F;&#x7684; 00:01 &#x53D1;&#x9001; n &#x4E2A;&#x8BF7;&#x6C42;,&#x8FD9;&#x6837;&#x5728; 2 &#x79D2;&#x949F;&#x5185;&#x8BF7;&#x6C42;&#x5230;&#x8FBE;&#x4E86; <code>2n - 1</code> &#x4E2A;.<ul>
<li>&#x8BBE;&#x6BCF;&#x5206;&#x949F;&#x8BF7;&#x6C42;&#x6570;&#x91CF;&#x4E3A; 60 &#x4E2A;,&#x6BCF;&#x79D2;&#x53EF;&#x4EE5;&#x5904;&#x7406; 1 &#x4E2A;&#x8BF7;&#x6C42;,&#x7528;&#x6237;&#x5728; 00:59 &#x53D1;&#x9001; 60 &#x4E2A;&#x8BF7;&#x6C42;,&#x5728; 01:00 &#x53D1;&#x9001; 60 &#x4E2A;&#x8BF7;&#x6C42; &#x6B64;&#x65F6; 2 &#x79D2;&#x949F;&#x6709; 120 &#x4E2A;&#x8BF7;&#x6C42;(&#x6BCF;&#x79D2; 60 &#x4E2A;&#x8BF7;&#x6C42;),&#x8FDC;&#x8FDC;&#x5927;&#x4E8E;&#x4E86;&#x6BCF;&#x79D2;&#x949F;&#x5904;&#x7406;&#x6570;&#x91CF;&#x7684;&#x9608;&#x503C;</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="&#x6ED1;&#x52A8;&#x7A97;&#x53E3;"><a name="&#x6ED1;&#x52A8;&#x7A97;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x6ED1;&#x52A8;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x6ED1;&#x52A8;&#x7A97;&#x53E3;" class="plugin-anchor" href="#&#x6ED1;&#x52A8;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6ED1;&#x52A8;&#x7A97;&#x53E3;</h3>
<h4 id="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;_1"><a name="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;_1" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;" class="plugin-anchor" href="#&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;</h4>
<p>&#x6ED1;&#x52A8;&#x7A97;&#x53E3;&#x7B97;&#x6CD5;&#x662F;&#x5C06;&#x65F6;&#x95F4;&#x5468;&#x671F;&#x5206;&#x4E3A;N&#x4E2A;&#x5C0F;&#x5468;&#x671F;&#xFF0C;&#x5206;&#x522B;&#x8BB0;&#x5F55;&#x6BCF;&#x4E2A;&#x5C0F;&#x5468;&#x671F;&#x5185;&#x8BBF;&#x95EE;&#x6B21;&#x6570;&#xFF0C;&#x5E76;&#x4E14;&#x6839;&#x636E;&#x65F6;&#x95F4;&#x6ED1;&#x52A8;&#x5220;&#x9664;&#x8FC7;&#x671F;&#x7684;&#x5C0F;&#x5468;&#x671F;&#x3002;</p>
<p>&#x5982;&#x4E0B;&#x56FE;&#xFF0C;&#x5047;&#x8BBE;&#x65F6;&#x95F4;&#x5468;&#x671F;&#x4E3A;1min&#xFF0C;&#x5C06;1min&#x518D;&#x5206;&#x4E3A;2&#x4E2A;&#x5C0F;&#x5468;&#x671F;&#xFF0C;&#x7EDF;&#x8BA1;&#x6BCF;&#x4E2A;&#x5C0F;&#x5468;&#x671F;&#x7684;&#x8BBF;&#x95EE;&#x6570;&#x91CF;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x65F6;&#x95F4;&#x5468;&#x671F;&#x5185;&#xFF0C;&#x8BBF;&#x95EE;&#x6570;&#x91CF;&#x4E3A;75&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x65F6;&#x95F4;&#x5468;&#x671F;&#x5185;&#xFF0C;&#x8BBF;&#x95EE;&#x6570;&#x91CF;&#x4E3A;100&#xFF0C;&#x8D85;&#x8FC7;100&#x7684;&#x8BBF;&#x95EE;&#x5219;&#x88AB;&#x9650;&#x6D41;&#x6389;&#x4E86;  </p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201218221431.png" alt="img"></p>
<p>&#x7531;&#x6B64;&#x53EF;&#x89C1;&#xFF0C;&#x5F53;&#x6ED1;&#x52A8;&#x7A97;&#x53E3;&#x7684;&#x683C;&#x5B50;&#x5212;&#x5206;&#x7684;&#x8D8A;&#x591A;&#xFF0C;&#x90A3;&#x4E48;&#x6ED1;&#x52A8;&#x7A97;&#x53E3;&#x7684;&#x6EDA;&#x52A8;&#x5C31;&#x8D8A;&#x5E73;&#x6ED1;&#xFF0C;&#x9650;&#x6D41;&#x7684;&#x7EDF;&#x8BA1;&#x5C31;&#x4F1A;&#x8D8A;&#x7CBE;&#x786E;&#x3002;</p>
<p>&#x6B64;&#x7B97;&#x6CD5;&#x53EF;&#x4EE5;&#x5F88;&#x597D;&#x7684;&#x89E3;&#x51B3;&#x56FA;&#x5B9A;&#x7A97;&#x53E3;&#x7B97;&#x6CD5;&#x7684;&#x4E34;&#x754C;&#x95EE;&#x9898;&#x3002;</p>
<ul>
<li>&#x6ED1;&#x52A8;&#x7A97;&#x53E3;&#x662F;&#x5BF9;&#x8BA1;&#x6570;&#x5668;&#x65B9;&#x5F0F;&#x7684;&#x6539;&#x8FDB;, &#x589E;&#x52A0;&#x4E00;&#x4E2A;&#x65F6;&#x95F4;&#x7C92;&#x5EA6;&#x7684;&#x5EA6;&#x91CF;&#x5355;&#x4F4D;<ul>
<li>&#x628A;&#x4E00;&#x5206;&#x949F;&#x5206;&#x6210;&#x82E5;&#x5E72;&#x7B49;&#x5206;(6 &#x4EFD;,&#x6BCF;&#x4EFD; 10 &#x79D2;), &#x5728;&#x6BCF;&#x4E00;&#x4EFD;&#x4E0A;&#x8BBE;&#x7F6E;&#x72EC;&#x7ACB;&#x8BA1;&#x6570;&#x5668;,&#x5728; 00:00-00:09 &#x4E4B;&#x95F4;&#x53D1;&#x751F;&#x8BF7;&#x6C42;&#x8BA1;&#x6570;&#x5668;&#x7D2F;&#x52A0; 1.&#x5F53;&#x7B49;&#x5206;&#x6570;&#x91CF;&#x8D8A;&#x5927;&#x9650;&#x6D41;&#x7EDF;&#x8BA1;&#x5C31;&#x8D8A;&#x8BE6;&#x7EC6;</li>
</ul>
</li>
</ul>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example.demo1.service;

<span class="hljs-keyword">import</span> java.util.Iterator;
<span class="hljs-keyword">import</span> java.util.Random;
<span class="hljs-keyword">import</span> java.util.concurrent.ConcurrentLinkedQueue;
<span class="hljs-keyword">import</span> java.util.stream.IntStream;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TimeWindow</span> </span>{
    <span class="hljs-keyword">private</span> ConcurrentLinkedQueue&lt;Long&gt; queue = <span class="hljs-keyword">new</span> ConcurrentLinkedQueue&lt;Long&gt;();

    <span class="hljs-comment">/**
     * &#x95F4;&#x9694;&#x79D2;&#x6570;
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> seconds;

    <span class="hljs-comment">/**
     * &#x6700;&#x5927;&#x9650;&#x6D41;
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> max;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">TimeWindow</span><span class="hljs-params">(<span class="hljs-keyword">int</span> max, <span class="hljs-keyword">int</span> seconds)</span> </span>{
        <span class="hljs-keyword">this</span>.seconds = seconds;
        <span class="hljs-keyword">this</span>.max = max;

        <span class="hljs-comment">/**
         * &#x6C38;&#x7EED;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x6E05;&#x7406;queue &#x4EFB;&#x52A1;
         */</span>
        <span class="hljs-keyword">new</span> Thread(() -&gt; {
            <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {
                <span class="hljs-keyword">try</span> {
                    <span class="hljs-comment">// &#x7B49;&#x5F85; &#x95F4;&#x9694;&#x79D2;&#x6570;-1 &#x6267;&#x884C;&#x6E05;&#x7406;&#x64CD;&#x4F5C;</span>
                    Thread.sleep((seconds - <span class="hljs-number">1</span>) * <span class="hljs-number">1000L</span>);
                } <span class="hljs-keyword">catch</span> (InterruptedException e) {
                    e.printStackTrace();
                }
                clean();
            }
        }).start();

    }

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> <span class="hljs-keyword">throws</span> Exception </span>{

        <span class="hljs-keyword">final</span> TimeWindow timeWindow = <span class="hljs-keyword">new</span> TimeWindow(<span class="hljs-number">10</span>, <span class="hljs-number">1</span>);

        <span class="hljs-comment">// &#x6D4B;&#x8BD5;3&#x4E2A;&#x7EBF;&#x7A0B;</span>
        IntStream.range(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>).forEach((i) -&gt; {
            <span class="hljs-keyword">new</span> Thread(() -&gt; {

                <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {

                    <span class="hljs-keyword">try</span> {
                        Thread.sleep(<span class="hljs-keyword">new</span> Random().nextInt(<span class="hljs-number">20</span>) * <span class="hljs-number">100</span>);
                    } <span class="hljs-keyword">catch</span> (InterruptedException e) {
                        e.printStackTrace();
                    }
                    timeWindow.take();
                }

            }).start();

        });

    }

    <span class="hljs-comment">/**
     * &#x83B7;&#x53D6;&#x4EE4;&#x724C;&#xFF0C;&#x5E76;&#x4E14;&#x6DFB;&#x52A0;&#x65F6;&#x95F4;
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">take</span><span class="hljs-params">()</span> </span>{

        <span class="hljs-keyword">long</span> start = System.currentTimeMillis();
        <span class="hljs-keyword">try</span> {

            <span class="hljs-keyword">int</span> size = sizeOfValid();
            <span class="hljs-keyword">if</span> (size &gt; max) {
                System.err.println(<span class="hljs-string">&quot;&#x8D85;&#x9650;&quot;</span>);

            }
            <span class="hljs-keyword">synchronized</span> (queue) {
                <span class="hljs-keyword">if</span> (sizeOfValid() &gt; max) {
                    System.err.println(<span class="hljs-string">&quot;&#x8D85;&#x9650;&quot;</span>);
                    System.err.println(<span class="hljs-string">&quot;queue&#x4E2D;&#x6709; &quot;</span> + queue.size() + <span class="hljs-string">&quot; &#x6700;&#x5927;&#x6570;&#x91CF; &quot;</span> + max);
                }
                <span class="hljs-keyword">this</span>.queue.offer(System.currentTimeMillis());
            }
            System.out.println(<span class="hljs-string">&quot;queue&#x4E2D;&#x6709; &quot;</span> + queue.size() + <span class="hljs-string">&quot; &#x6700;&#x5927;&#x6570;&#x91CF; &quot;</span> + max);

        }

    }

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">sizeOfValid</span><span class="hljs-params">()</span> </span>{
        Iterator&lt;Long&gt; it = queue.iterator();
        Long ms = System.currentTimeMillis() - seconds * <span class="hljs-number">1000</span>;
        <span class="hljs-keyword">int</span> count = <span class="hljs-number">0</span>;
        <span class="hljs-keyword">while</span> (it.hasNext()) {
            <span class="hljs-keyword">long</span> t = it.next();
            <span class="hljs-keyword">if</span> (t &gt; ms) {
                <span class="hljs-comment">// &#x5728;&#x5F53;&#x524D;&#x7684;&#x7EDF;&#x8BA1;&#x65F6;&#x95F4;&#x8303;&#x56F4;&#x5185;</span>
                count++;
            }
        }

        <span class="hljs-keyword">return</span> count;
    }

    <span class="hljs-comment">/**
     * &#x6E05;&#x7406;&#x8FC7;&#x671F;&#x7684;&#x65F6;&#x95F4;
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">clean</span><span class="hljs-params">()</span> </span>{
        Long c = System.currentTimeMillis() - seconds * <span class="hljs-number">1000</span>;

        Long tl = <span class="hljs-keyword">null</span>;
        <span class="hljs-keyword">while</span> ((tl = queue.peek()) != <span class="hljs-keyword">null</span> &amp;&amp; tl &lt; c) {
            System.out.println(<span class="hljs-string">&quot;&#x6E05;&#x7406;&#x6570;&#x636E;&quot;</span>);
            queue.poll();
        }
    }

}
</code></pre>
<h3 id="&#x6F0F;&#x6876;&#x7B97;&#x6CD5;"><a name="&#x6F0F;&#x6876;&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x6F0F;&#x6876;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x6F0F;&#x6876;&#x7B97;&#x6CD5;" class="plugin-anchor" href="#&#x6F0F;&#x6876;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6F0F;&#x6876;&#x7B97;&#x6CD5;</h3>
<h4 id="&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x7B80;&#x4ECB;"><a name="&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x7B80;&#x4ECB;" class="anchor-navigation-ex-anchor" href="#&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x7B80;&#x4ECB;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x7B80;&#x4ECB;" class="plugin-anchor" href="#&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x7B80;&#x4ECB;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x7B80;&#x4ECB;</strong></h4>
<p>&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#xFF0C;&#x53C8;&#x79F0;leaky bucket&#x3002;&#x4E3A;&#x4E86;&#x7406;&#x89E3;&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E0B;&#x5BF9;&#x4E8E;&#x8BE5;&#x7B97;&#x6CD5;&#x7684;&#x793A;&#x610F;&#x56FE;&#xFF1A;</p>
<p><img src="https://gitee.com/zisuu/picture/raw/master/img/20201218221925.png" alt="image-20201218221924976"></p>
<p>&#x4ECE;&#x56FE;&#x4E2D;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x6574;&#x4E2A;&#x7B97;&#x6CD5;&#x5176;&#x5B9E;&#x5341;&#x5206;&#x7B80;&#x5355;&#x3002;&#x9996;&#x5148;&#xFF0C;&#x6211;&#x4EEC;&#x6709;&#x4E00;&#x4E2A;&#x56FA;&#x5B9A;&#x5BB9;&#x91CF;&#x7684;&#x6876;&#xFF0C;&#x6709;&#x6C34;&#x6D41;&#x8FDB;&#x6765;&#xFF0C;&#x4E5F;&#x6709;&#x6C34;&#x6D41;&#x51FA;&#x53BB;&#x3002;&#x5BF9;&#x4E8E;&#x6D41;&#x8FDB;&#x6765;&#x7684;&#x6C34;&#x6765;&#x8BF4;&#xFF0C;&#x6211;&#x4EEC;&#x65E0;&#x6CD5;&#x9884;&#x8BA1;&#x4E00;&#x5171;&#x6709;&#x591A;&#x5C11;&#x6C34;&#x4F1A;&#x6D41;&#x8FDB;&#x6765;&#xFF0C;&#x4E5F;&#x65E0;&#x6CD5;&#x9884;&#x8BA1;&#x6C34;&#x6D41;&#x7684;&#x901F;&#x5EA6;&#x3002;&#x4F46;&#x662F;&#x5BF9;&#x4E8E;&#x6D41;&#x51FA;&#x53BB;&#x7684;&#x6C34;&#x6765;&#x8BF4;&#xFF0C;&#x8FD9;&#x4E2A;&#x6876;&#x53EF;&#x4EE5;&#x56FA;&#x5B9A;&#x6C34;&#x6D41;&#x51FA;&#x7684;&#x901F;&#x7387;&#x3002;&#x800C;&#x4E14;&#xFF0C;&#x5F53;&#x6876;&#x6EE1;&#x4E86;&#x4E4B;&#x540E;&#xFF0C;&#x591A;&#x4F59;&#x7684;&#x6C34;&#x5C06;&#x4F1A;&#x6EA2;&#x51FA;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5C06;&#x7B97;&#x6CD5;&#x4E2D;&#x7684;&#x6C34;&#x6362;&#x6210;&#x5B9E;&#x9645;&#x5E94;&#x7528;&#x4E2D;&#x7684;&#x8BF7;&#x6C42;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x5929;&#x751F;&#x5C31;&#x9650;&#x5236;&#x4E86;&#x8BF7;&#x6C42;&#x7684;&#x901F;&#x5EA6;&#x3002;&#x5F53;&#x4F7F;&#x7528;&#x4E86;&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x63A5;&#x53E3;&#x4F1A;&#x4EE5;&#x4E00;&#x4E2A;&#x5E38;&#x901F;&#x901F;&#x7387;&#x6765;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#x3002;&#x6240;&#x4EE5;&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x5929;&#x751F;&#x4E0D;&#x4F1A;&#x51FA;&#x73B0;&#x4E34;&#x754C;&#x95EE;&#x9898;&#x3002;</p>
<p>&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x53EF;&#x4EE5;&#x7C97;&#x7565;&#x7684;&#x8BA4;&#x4E3A;&#x5C31;&#x662F;&#x6CE8;&#x6C34;&#x6F0F;&#x6C34;&#x8FC7;&#x7A0B;&#xFF0C;&#x5F80;&#x6876;&#x4E2D;&#x4EE5;&#x4E00;&#x5B9A;&#x901F;&#x7387;&#x6D41;&#x51FA;&#x6C34;&#xFF0C;&#x4EE5;&#x4EFB;&#x610F;&#x901F;&#x7387;&#x6D41;&#x5165;&#x6C34;&#xFF0C;&#x5F53;&#x6C34;&#x8D85;&#x8FC7;&#x6876;&#x6D41;&#x91CF;&#x5219;&#x4E22;&#x5F03;&#xFF0C;&#x56E0;&#x4E3A;&#x6876;&#x5BB9;&#x91CF;&#x662F;&#x4E0D;&#x53D8;&#x7684;&#xFF0C;&#x4FDD;&#x8BC1;&#x4E86;&#x6574;&#x4F53;&#x7684;&#x901F;&#x7387;&#x3002;</p>
<p><strong>&#x4E8C;&#x3001;&#x6F0F;&#x6876;&#x7B97;&#x6CD5;&#x5C0F;&#x6817;&#x5B50;</strong></p>
<p>&#x6765;&#x770B;&#x4E2A;&#x5C0F;&#x6817;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LeakyBucket</span> </span>{
        <span class="hljs-keyword">public</span> <span class="hljs-keyword">long</span> timeStamp = System.currentTimeMillis();  <span class="hljs-comment">// &#x5F53;&#x524D;&#x65F6;&#x95F4;</span>
        <span class="hljs-keyword">public</span> <span class="hljs-keyword">long</span> capacity; <span class="hljs-comment">// &#x6876;&#x7684;&#x5BB9;&#x91CF;</span>
        <span class="hljs-keyword">public</span> <span class="hljs-keyword">long</span> rate; <span class="hljs-comment">// &#x6C34;&#x6F0F;&#x51FA;&#x7684;&#x901F;&#x5EA6;</span>
        <span class="hljs-keyword">public</span> <span class="hljs-keyword">long</span> water; <span class="hljs-comment">// &#x5F53;&#x524D;&#x6C34;&#x91CF;(&#x5F53;&#x524D;&#x7D2F;&#x79EF;&#x8BF7;&#x6C42;&#x6570;)</span>

        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">grant</span><span class="hljs-params">()</span> </span>{
            <span class="hljs-keyword">long</span> now = System.currentTimeMillis();
            <span class="hljs-comment">// &#x5148;&#x6267;&#x884C;&#x6F0F;&#x6C34;&#xFF0C;&#x8BA1;&#x7B97;&#x5269;&#x4F59;&#x6C34;&#x91CF;</span>
            water = Math.max(<span class="hljs-number">0</span>, water - (now - timeStamp) * rate); 

            timeStamp = now;
            <span class="hljs-keyword">if</span> ((water + <span class="hljs-number">1</span>) &lt; capacity) {
                <span class="hljs-comment">// &#x5C1D;&#x8BD5;&#x52A0;&#x6C34;,&#x5E76;&#x4E14;&#x6C34;&#x8FD8;&#x672A;&#x6EE1;</span>
                water += <span class="hljs-number">1</span>;
                <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
            } <span class="hljs-keyword">else</span> {
                <span class="hljs-comment">// &#x6C34;&#x6EE1;&#xFF0C;&#x62D2;&#x7EDD;&#x52A0;&#x6C34;</span>
                <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
        }
    }
}
</code></pre>
<p><strong>&#x8BF4;&#x660E;&#xFF1A;</strong></p>
<blockquote>
<p>&#xFF08;1&#xFF09;&#x672A;&#x6EE1;&#x52A0;&#x6C34;&#xFF1A;&#x901A;&#x8FC7;&#x4EE3;&#x7801; water +=1&#x8FDB;&#x884C;&#x4E0D;&#x505C;&#x52A0;&#x6C34;&#x7684;&#x52A8;&#x4F5C;&#x3002;
&#xFF08;2&#xFF09;&#x6F0F;&#x6C34;&#xFF1A;&#x901A;&#x8FC7;&#x65F6;&#x95F4;&#x5DEE;&#x6765;&#x8BA1;&#x7B97;&#x6F0F;&#x6C34;&#x91CF;&#x3002;
&#xFF08;3&#xFF09;&#x5269;&#x4F59;&#x6C34;&#x91CF;&#xFF1A;&#x603B;&#x6C34;&#x91CF;-&#x6F0F;&#x6C34;&#x91CF;&#x3002;</p>
</blockquote>
<h3 id="&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;"><a name="&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;" class="plugin-anchor" href="#&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EE4;&#x724C;&#x6876;&#x7B97;&#x6CD5;</h3>
<h4 id="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;_2"><a name="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;_2" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;_2"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;" class="plugin-anchor" href="#&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x73B0;&#x65B9;&#x5F0F;</h4>
<ul>
<li>&#x89C4;&#x5B9A;&#x56FA;&#x5B9A;&#x5BB9;&#x91CF;&#x7684;&#x6876;, token &#x4EE5;&#x56FA;&#x5B9A;&#x901F;&#x5EA6;&#x5F80;&#x6876;&#x5185;&#x586B;&#x5145;, &#x5F53;&#x6876;&#x6EE1;&#x65F6; token &#x4E0D;&#x4F1A;&#x88AB;&#x7EE7;&#x7EED;&#x653E;&#x5165;, &#x6BCF;&#x8FC7;&#x6765;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x628A; token &#x4ECE;&#x6876;&#x4E2D;&#x79FB;&#x9664;, &#x5982;&#x679C;&#x6876;&#x4E2D;&#x6CA1;&#x6709; token &#x4E0D;&#x80FD;&#x8BF7;&#x6C42;</li>
</ul>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TokenBucket</span> </span>{
    <span class="hljs-comment">/**
     * &#x65F6;&#x95F4;
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">long</span> time;
    <span class="hljs-comment">/**
     * &#x603B;&#x91CF;
     */</span>
    <span class="hljs-keyword">private</span> Double total;
    <span class="hljs-comment">/**
     * token &#x653E;&#x5165;&#x901F;&#x5EA6;
     */</span>
    <span class="hljs-keyword">private</span> Double rate;
    <span class="hljs-comment">/**
     * &#x5F53;&#x524D;&#x603B;&#x91CF;
     */</span>
    <span class="hljs-keyword">private</span> Double nowSize;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">limit</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">long</span> now = System.currentTimeMillis();
        nowSize = Math.min(total, nowSize + (now - time) * rate);
        time = now;
        <span class="hljs-keyword">if</span> (nowSize &lt; <span class="hljs-number">1</span>) {
            <span class="hljs-comment">// &#x6876;&#x91CC;&#x6CA1;&#x6709;token</span>
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">// &#x5B58;&#x5728;token</span>
            nowSize -= <span class="hljs-number">1</span>;
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
        }
    }

}
</code></pre>
<h2 id="&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;"><a name="&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;" class="plugin-anchor" href="#&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5DE5;&#x4F5C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;</h2>
<h3 id="spring-cloud-gateway"><a name="spring-cloud-gateway" class="anchor-navigation-ex-anchor" href="#spring-cloud-gateway"><i class="fa fa-link" aria-hidden="true"></i></a><a name="spring-cloud-gateway" class="plugin-anchor" href="#spring-cloud-gateway"><i class="fa fa-link" aria-hidden="true"></i></a>spring cloud gateway</h3>
<ul>
<li>spring cloud gateway &#x9ED8;&#x8BA4;&#x4F7F;&#x7528; redis &#x8FDB;&#x884C;&#x9650;&#x6D41;, &#x7B14;&#x8005;&#x4E00;&#x822C;&#x53EA;&#x662F;&#x4FEE;&#x6539;&#x4FEE;&#x6539;&#x53C2;&#x6570;&#x5C5E;&#x4E8E;&#x62FF;&#x6765;&#x5373;&#x7528;. &#x5E76;&#x6CA1;&#x6709;&#x53BB;&#x4ECE;&#x5934;&#x5B9E;&#x73B0;&#x4E0A;&#x8FF0;&#x90A3;&#x4E9B;&#x7B97;&#x6CD5;.</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.cloud<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-cloud-starter-gateway<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-data-redis-reactive<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<pre><code class="lang-yaml"><span class="hljs-attr">spring:</span>
<span class="hljs-attr">  cloud:</span>
<span class="hljs-attr">    gateway:</span>
<span class="hljs-attr">      routes:</span>
<span class="hljs-attr">        - id:</span> requestratelimiter_route

<span class="hljs-attr">          uri:</span> lb://pigx-upms
<span class="hljs-attr">          order:</span> <span class="hljs-number">10000</span>
<span class="hljs-attr">          predicates:</span>
<span class="hljs-bullet">            -</span> Path=/admin/**

<span class="hljs-attr">          filters:</span>
<span class="hljs-attr">            - name:</span> RequestRateLimiter

<span class="hljs-attr">              args:</span>
                redis-rate-limiter.replenishRate: <span class="hljs-number">1</span> <span class="hljs-comment"># &#x4EE4;&#x724C;&#x6876;&#x7684;&#x5BB9;&#x79EF;</span>
                redis-rate-limiter.burstCapacity: <span class="hljs-number">3</span> <span class="hljs-comment"># &#x6D41;&#x901F; &#x6BCF;&#x79D2;</span>
<span class="hljs-attr">                key-resolver:</span> <span class="hljs-string">&quot;#{@remoteAddrKeyResolver}&quot;</span> <span class="hljs-comment">#SPEL&#x8868;&#x8FBE;&#x5F0F;&#x53BB;&#x7684;&#x5BF9;&#x5E94;&#x7684;bean</span>

<span class="hljs-bullet">            -</span> StripPrefix=<span class="hljs-number">1</span>
</code></pre>
<pre><code class="lang-java"><span class="hljs-meta">@Bean</span>
<span class="hljs-function">KeyResolver <span class="hljs-title">remoteAddrKeyResolver</span><span class="hljs-params">()</span> </span>{
    <span class="hljs-keyword">return</span> exchange -&gt; Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
}
</code></pre>
<h3 id="sentinel"><a name="sentinel" class="anchor-navigation-ex-anchor" href="#sentinel"><i class="fa fa-link" aria-hidden="true"></i></a><a name="sentinel" class="plugin-anchor" href="#sentinel"><i class="fa fa-link" aria-hidden="true"></i></a>sentinel</h3>
<ul>
<li>&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x6765;&#x63A7;&#x5236;&#x6BCF;&#x4E2A; url &#x7684;&#x6D41;&#x91CF;</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.alibaba.cloud<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-cloud-starter-alibaba-sentinel<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<pre><code class="lang-yaml"><span class="hljs-attr">spring:</span>
<span class="hljs-attr">  cloud:</span>
<span class="hljs-attr">    nacos:</span>
<span class="hljs-attr">      discovery:</span>
<span class="hljs-attr">        server-addr:</span> localhost:<span class="hljs-number">8848</span>
<span class="hljs-attr">    sentinel:</span>
<span class="hljs-attr">      transport:</span>
<span class="hljs-attr">        dashboard:</span> localhost:<span class="hljs-number">8080</span>
<span class="hljs-attr">        port:</span> <span class="hljs-number">8720</span>
<span class="hljs-attr">      datasource:</span>
<span class="hljs-attr">        ds:</span>
<span class="hljs-attr">          nacos:</span>
<span class="hljs-attr">            server-addr:</span> localhost:<span class="hljs-number">8848</span>
<span class="hljs-attr">            dataId:</span> spring-cloud-sentinel-nacos
<span class="hljs-attr">            groupId:</span> DEFAULT_GROUP
<span class="hljs-attr">            rule-type:</span> flow
<span class="hljs-attr">            namespace:</span> xxxxxxxx
</code></pre>
<ul>
<li>&#x914D;&#x7F6E;&#x5185;&#x5BB9;&#x5728; nacos &#x4E0A;&#x8FDB;&#x884C;&#x7F16;&#x8F91;</li>
</ul>
<pre><code class="lang-json">[
  {
    <span class="hljs-string">&quot;resource&quot;</span>: <span class="hljs-string">&quot;/hello&quot;</span>,
    <span class="hljs-string">&quot;limitApp&quot;</span>: <span class="hljs-string">&quot;default&quot;</span>,
    <span class="hljs-string">&quot;grade&quot;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-string">&quot;count&quot;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-string">&quot;strategy&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;controlBehavior&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;clusterMode&quot;</span>: <span class="hljs-literal">false</span>
  }
]
</code></pre>
<ul>
<li>resource&#xFF1A;&#x8D44;&#x6E90;&#x540D;&#xFF0C;&#x5373;&#x9650;&#x6D41;&#x89C4;&#x5219;&#x7684;&#x4F5C;&#x7528;&#x5BF9;&#x8C61;&#x3002;</li>
<li>limitApp&#xFF1A;&#x6D41;&#x63A7;&#x9488;&#x5BF9;&#x7684;&#x8C03;&#x7528;&#x6765;&#x6E90;&#xFF0C;&#x82E5;&#x4E3A; default &#x5219;&#x4E0D;&#x533A;&#x5206;&#x8C03;&#x7528;&#x6765;&#x6E90;&#x3002;</li>
<li>grade&#xFF1A;&#x9650;&#x6D41;&#x9608;&#x503C;&#x7C7B;&#x578B;&#xFF0C;QPS &#x6216;&#x7EBF;&#x7A0B;&#x6570;&#x6A21;&#x5F0F;&#xFF0C;0 &#x4EE3;&#x8868;&#x6839;&#x636E;&#x5E76;&#x53D1;&#x6570;&#x91CF;&#x6765;&#x9650;&#x6D41;&#xFF0C;1 &#x4EE3;&#x8868;&#x6839;&#x636E; QPS &#x6765;&#x8FDB;&#x884C;&#x6D41;&#x91CF;&#x63A7;&#x5236;&#x3002;</li>
<li>count&#xFF1A;&#x9650;&#x6D41;&#x9608;&#x503C;</li>
<li>strategy&#xFF1A;&#x5224;&#x65AD;&#x7684;&#x6839;&#x636E;&#x662F;&#x8D44;&#x6E90;&#x81EA;&#x8EAB;&#xFF0C;&#x8FD8;&#x662F;&#x6839;&#x636E;&#x5176;&#x5B83;&#x5173;&#x8054;&#x8D44;&#x6E90; (refResource)&#xFF0C;&#x8FD8;&#x662F;&#x6839;&#x636E;&#x94FE;&#x8DEF;&#x5165;&#x53E3;</li>
<li>controlBehavior&#xFF1A;&#x6D41;&#x63A7;&#x6548;&#x679C;&#xFF08;&#x76F4;&#x63A5;&#x62D2;&#x7EDD; / &#x6392;&#x961F;&#x7B49;&#x5F85; / &#x6162;&#x542F;&#x52A8;&#x6A21;&#x5F0F;&#xFF09;</li>
<li>clusterMode&#xFF1A;&#x662F;&#x5426;&#x4E3A;&#x96C6;&#x7FA4;&#x6A21;&#x5F0F;</li>
</ul>
<h3 id="&#x603B;&#x7ED3;"><a name="&#x603B;&#x7ED3;" class="anchor-navigation-ex-anchor" href="#&#x603B;&#x7ED3;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x603B;&#x7ED3;" class="plugin-anchor" href="#&#x603B;&#x7ED3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x603B;&#x7ED3;</h3>
<blockquote>
<p>sentinel &#x548C; spring cloud gateway &#x4E24;&#x4E2A;&#x6846;&#x67B6;&#x90FD;&#x662F;&#x5F88;&#x597D;&#x7684;&#x9650;&#x6D41;&#x6846;&#x67B6;, &#x4F46;&#x662F;&#x5728;&#x6211;&#x4F7F;&#x7528;&#x4E2D;&#x8FD8;&#x6CA1;&#x6709;&#x5C06;<a href="https://github.com/alibaba/spring-cloud-alibaba" target="_blank">spring-cloud-alibaba</a>&#x63A5;&#x5165;&#x5230;&#x9879;&#x76EE;&#x4E2D;&#x8FDB;&#x884C;&#x4F7F;&#x7528;, &#x6240;&#x4EE5;&#x6211;&#x4F1A;&#x9009;&#x62E9;<strong>spring cloud gateway</strong>, &#x5F53;&#x63A5;&#x5165;&#x5B8C;&#x6574;&#x7684;&#x6216;&#x8005;&#x63A5;&#x5165; Nacos &#x9879;&#x76EE;&#x4F7F;&#x7528; setinel &#x4F1A;&#x6709;&#x66F4;&#x52A0;&#x597D;&#x7684;&#x4F53;&#x9A8C;.</p>
</blockquote>

<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../架构/0.微服务架构与soa架构.html" class="navigation navigation-prev " aria-label="Previous page: 2.微服务架构与soa架构">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../高可用系统/2.服务熔断.html" class="navigation navigation-next " aria-label="Next page: 2.服务熔断">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1.系统限流","level":"12.1","depth":1,"next":{"title":"2.服务熔断","level":"12.2","depth":1,"path":"高可用系统/2.服务熔断.md","ref":"高可用系统/2.服务熔断.md","articles":[]},"previous":{"title":"2.微服务架构与soa架构","level":"11.2","depth":1,"path":"架构/0.微服务架构与soa架构.md","ref":"架构/0.微服务架构与soa架构.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","sharing-plus","anchor-navigation-ex","favicon","expandable-chapters","toggle-chapters","back-to-top-button","code","-lunr","-search","search-pro","pageview-count","popup","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"livereload":{},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{},"expandable-chapters":{}},"theme":"default","author":"hzh","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"计算机 ,java , 大数据 基础知识体系","language":"zh-hans","gitbook":"3.2.3"},"file":{"path":"高可用架构/1.限流.md","mtime":"2020-12-18T14:22:47.999Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-30T11:12:56.611Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

